#!/bin/sh
# Copyright (C) 2000-2016 Synology Inc. All rights reserved.
#SYNOPKG_PKGDEST=/synokvm

ln -sf $SYNOPKG_PKGDEST/synokvm /usr/local/

#echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/synokvm/lib' >> /root/.bashrc
echo 'export PATH=$PATH:/usr/local/synokvm/bin' >> /root/.bashrc

ln -sf $SYNOPKG_PKGDEST/synokvm/sbin/ldconfig* /sbin/
ln -sf $SYNOPKG_PKGDEST/synokvm/sbin/ebtables /usr/sbin/ebtables
ln -sf $SYNOPKG_PKGDEST/synokvm/sbin/dnsmasq /usr/sbin/dnsmasq
ln -sf $SYNOPKG_PKGDEST/synokvm/sbin/pm-is-supported /usr/sbin/pm-is-supported

echo "/usr/local/synokvm/lib" >> /etc/ld.so.conf
ldconfig &

chmod +x /usr/local/synokvm/libexec/libvirt_leaseshelper
cd /usr/local/synokvm/lib
ln -sf libvirt.so.0.3009.0            libvirt.so.0
ln -sf libvirt.so.0.3009.0            libvirt.so
ln -sf libvirt-qemu.so.0.3009.0       libvirt-qemu.so.0 
ln -sf libvirt-qemu.so.0.3009.0       libvirt-qemu.so
ln -sf libvirt-lxc.so.0.3009.0        libvirt-lxc.so.0
ln -sf libvirt-lxc.so.0.3009.0        libvirt-lxc.so
ln -sf libvirt-admin.so.0.3009.0      libvirt-admin.so.0
ln -sf libvirt-admin.so.0.3009.0      libvirt-admin.so

export PYTHONPATH=$PYTHONPATH:/usr/local/synokvm/python2.7/site-packages
python2 /usr/local/synokvm/webvirtmgr/autouser.py -u ${webvirtmgr_user} -p ${webvirtmgr_pass}

exit 0
